module cl {
	export class Campaign {

		public static data : CampaignDataEx;

		public static time_ref : TimeReference;

		public static force : ForceEx[];

		public static troop_type : TroopTypeEx[];

		public static troop : TroopEx[];

		public static zone : Zone;

		public static troop_force : number[];

		public static troop_plane : number[]; // -1:dieTroop 0:innerTroop 1:courtTroop

		public static troop_map : number[]; // -1:tid has no troop, N: tid has troopid:N

		public static init(campaignData : CampaignData) : void {
			Campaign.setData(new CampaignDataEx(campaignData));
			Campaign.data.init();
			Campaign.cacheCommon();
		}

		public static setData(campaignData : CampaignDataEx) : void {
			Campaign.data = campaignData;

			Campaign.time_ref = Campaign.data.time_ref;
			Campaign.force = Campaign.data.force;
			Campaign.troop_type = Campaign.data.troop_type;
			Campaign.troop = Campaign.data.troop;
			Campaign.zone = Campaign.data.zone;
		}

		public static cacheCommon() : void {
			// 部队所属势力 和 是否域外部队 的缓存
			Campaign.troop_force = [];
			Campaign.troop_plane = [];
			Campaign.troop_map = Util.createArray(Campaign.zone.xsize * Campaign.zone.ysize, -1);
			for (let troopid = 0; troopid < Campaign.troop.length; troopid++) {
				let troop = Campaign.troop[troopid];
				Campaign.troop_force.push(troop.force);
				Campaign.troop_plane.push(troop.plane);
				if (troop.plane == 0) {
					Campaign.troop_map[troop.tid] = troopid;
				}
			}
		}
	}
}